package com.vcredit.creditcat.manager;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.vcredit.creditcat.api.IAppTokenManager;
import com.vcredit.creditcat.exception.AppTokenException;
import com.vcredit.creditcat.model.CustAccount;
import com.vcredit.creditcat.service.AppTokenService;
import com.vcredit.framework.annotation.Log;

@Service(protocol = { "protocol1" }, version = "1.0")
public class AppTokenManager implements IAppTokenManager {

	@Autowired
	private AppTokenService appTokenService;

	@Log
	public void checkAppToken(String token) throws AppTokenException {
		appTokenService.checkAppToken(token);
	}

	public String checkAppToken(String token, Long custId, Long accountId) throws AppTokenException {
		return appTokenService.checkAppToken(token, custId, accountId);
	}

	public String getLoginNameFromToken(String token) throws AppTokenException {
		return appTokenService.getLoginNameFromToken(token);
	}

	public Long getCustIdFromToken(String token) throws AppTokenException {
		return appTokenService.getCustIdFromToken(token);
	}

	@Override
	public Long getAccountIdFromToken(String token) throws AppTokenException {
		return appTokenService.getAccountIdFromToken(token);
	}

	@Override
	public boolean tokenIsVaild(CustAccount custAccount,String appToken) throws Exception {
		// TODO Auto-generated method stub
		return appTokenService.tokenIsVaild(custAccount, appToken);
	}

}
